home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Floppyshop 2
/
Floppyshop - 2.zip
/
Floppyshop - 2.iso
/
diskmags
/
0022-3.564
/
dmg-0143
/
articles
/
sample.doc
< prev
next >
Wrap
Text File
|
1997-04-16
|
2KB
|
94 lines
-------------------
STE SAMPLE PLAYING!
-------------------
Written by Paul Bramwell
Those of you with an STE like me will feel the lack of support in
games, this to change soon, you may have a few STE Demos like
Black Cats Demo or whatever, these use the enhanced sound chip
and sample chip the DMA chip.
These routines supplied will also use the DMA chip, which enables
us to get on with something else while we are playing a sample.
The routines supplied are based around the Mastersound playback
routines.
------------
HOW TO DO IT
------------
First of all we need to set up some memory for our sample, we do
this using DIM A%(Value), you should have come across this by
now.
DIM Sample%(5000) ! Sets up some memory
sample%=VARPTR(b%(0))
The next step is to load the sample into this space, we do this
using the Bmove command.
BLOAD "backbed.sam",sample%
The length of the sample supplied is about 30k, so we setup this
value as follows
length%=30000 ! Length of sample
dma%=&HFF8901 ! Sets up DMA value
Now we need to reset the DMA chip so we SPOKE it,
SPOKE dma%,0 ! Resets DMA
Next we setup the sample rate and a single mono channel.
SPOKE dma%+32,&H81
SPOKE dma%+2,sample%/&H10000 ! Start, count addresses
SPOKE dma%+4,sample%/&H100
SPOKE dma%+6,sample% AND &HFF
SPOKE dma%+8,sample%/&H10000
SPOKE dma%+&HA,sample%/&H100
SPOKE dma%+&HC,sample% AND &HFF
SPOKE dma%+&HE,(sample%+length%)/&H10000
SPOKE dma%+&H10,(sample%+length%)/&H100
SPOKE dma%+&H12,(sample%+length%) AND &HFF
Now you can put your main program here and then recall the sample
using
SPOKE dma%,1
FOR n%=0 TO 50
VSYNC
NEXT n%
And thats all there is to it!
To change the playback rate we just do this:
FOR speed%=0 TO 3
SPOKE dma%+32,&H80+speed%
SPOKE dma%,3 ! Loop DMA
FOR n%=0 TO 100
VSYNC
NEXT n%
NEXT speed%
SPOKE dma%,0 ! End sound
End
If you have a long sample, and you want it interupt driven just
take out the SPOKE dma%,0 out, this will make the sample keep
playing.
The listing is on the disk, in the GOODIES\GFA folders.